home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-14 | 3.6 KB | 141 lines | [TEXT/MPCC] |
- // Text Media Sample Code - QuickTime routines
- //
- // This file contains general purpose QuickTime and Utility routines
- //
- // sample to show how to do searches with text media, and how to use
- // a simple text proc to get the text (without the style info) out and
- // to display it in a window.
- //
- // This is something of a work in progress, it contains a few bugs, if you find
- // anthing that you feel needs fixing, or explaing, please let me know
- // AppleLink: NICKT
- //
- // Modification History
- //
- // 10/13/94 nick First cut - factored code out from other files
- //
- // Copyright: © 1992-4 by Apple Computer, Inc.
-
-
-
- #include "QuickTimeUtils.h"
-
- //---------------------------------------------------------------------
-
- void CheckError(OSErr error, Str255 displayString)
- {
- // hacky error handler. It's good to check errors, but this is not
- // really the best way to do it - checking should be more forgiving
- // and the way we are handling errors here is to just quit.
-
- // also this way of doing things uses hardwired strings. This is bad
- // because it makes localisation tough to do.
-
- Str255 theErrorAsString ;
-
- if (error == noErr) return;
-
- NumToString( error, theErrorAsString ) ;
- ParamText( displayString, theErrorAsString, "\p", "\p" ) ;
- (void)StopAlert( 130, nil ) ;
-
- ExitToShell();
- }
-
- //---------------------------------------------------------------------
- // Check to see if a window belongs to a desk accessory.
-
- Boolean IsDAWindow(WindowPtr window)
- {
- if ( window == nil )
- return false;
- else // DA windows have negative windowKinds
- return ((WindowPeek) window)->windowKind < 0;
- }
-
- //---------------------------------------------------------------------
-
- Boolean IsQuickTimeInstalled (void)
- {
- short error;
- long result;
-
- error = Gestalt (gestaltQuickTime, &result);
- return (error == noErr);
- }
-
- //---------------------------------------------------------------------
-
- OSErr DoPrerollMovie( Movie aMovie )
- {
- TimeValue aTimeValue ;
- TimeValue movieDur ;
- Fixed preferredRate ;
- OSErr theErr = noErr ;
-
- aTimeValue = GetMovieTime(aMovie, nil);
- movieDur = GetMovieDuration(aMovie);
- preferredRate = GetMoviePreferredRate(aMovie);
-
- if (aTimeValue == movieDur)
- aTimeValue = 0;
-
- theErr = PrerollMovie(aMovie, aTimeValue, preferredRate);
-
- return theErr ;
- }
-
- //---------------------------------------------------------------------
-
- Boolean IsPointInMovieController( MovieController aController, WindowPtr whichWindow, Point where)
- {
- RgnHandle rgn ;
- Boolean result = false ;
-
- rgn = MCGetWindowRgn( aController, whichWindow ) ;
- if( rgn != nil ) {
- result = PtInRgn( where, rgn ) ;
- DisposeRgn( rgn ) ;
- }
- return result ;
- }
-
- //---------------------------------------------------------------------
- // locate the first track in a movie with the supplied type
- Track GetFirstTrackOfType( Movie aMovie, OSType trackType )
- {
- Track theTrack = nil ;
- OSType mediaType;
- short trackCount ;
- short index ;
-
- trackCount = GetMovieTrackCount(aMovie);
- for ( index=1 ; index <= trackCount ; index++) {
- Track t = GetMovieIndTrack(aMovie, index);
-
- GetMediaHandlerDescription(GetTrackMedia(t), &mediaType, nil, nil);
- if (mediaType == trackType) {
- theTrack = t;
- break;
- }
- }
-
- return theTrack ;
-
- }
-
- //-----------------------------------------------------------------------
- // put up standard file - return true if we choose a movie
-
- Boolean GetAMovieFileSpec (FSSpec *theFile)
- {
- SFTypeList typeList = {MovieFileType,0,0,0};
- StandardFileReply reply;
-
- StandardGetFilePreview (nil, 1, typeList, &reply);
- if (reply.sfGood) {
- *theFile = reply.sfFile ;
- }
- return reply.sfGood;
- }
-